﻿@model IEnumerable<EventSys.BussinesEntities.webpages_Roles>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script type="text/javascript">

    function OnSuccessAdd(data) {
        console.log("agregando ventana");
        $("#dialogAddRoles").dialog({
            modal: true,
            width: 400,
            //autoOpen: false,
            show: {
                effect: "shake",
                duration: 1000
            },
            buttons: {
                'Cerrar': function () {
                    $(this).dialog('close');
                },
                //------------------------------
                'Guardar': function () {
                    $("#frmGuardar").submit();
                    $.validator.unobtrusive.parse('#frmGuardar');
                    location.reload();//para refrescar la pagina, es decir actualizar los recien ingresado
                    $(this).dialog('close');
                    
                }
            },
            close: function () {
                $(this).parent().remove();
                $(this).remove();
            }
        });

    }
</script>


<fieldset>
<legend><h2><b>Roles Registrados</b></h2></legend>

<p>
   @* @Html.ActionLink("Crear Rol","NuevoRol","Roles")*@

    @Ajax.ActionLink("Crear Rol","Create",new AjaxOptions()
           {
               Url = Url.Action("Create", "Roles"),
               UpdateTargetId = "showAdd",
               OnSuccess = "OnSuccessAdd"
           })

</p>
<div class="CSSTableGenerator">

<table>
    <tr>
        <th>
            Nº
            @*@Html.DisplayNameFor(model => model.RoleId)*@
        </th>
        <th>
            Nombre de Rol
            @*@Html.DisplayNameFor(model => model.RoleName)*@
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.RoleId)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.RoleName)
        </td>
        <td>
            @Html.ActionLink("Editar", "Edit", new { id=item.RoleId}) |
           @* @Html.ActionLink("Detalles", "Details", new { id=item.RoleId }) |*@
            @Html.ActionLink("Eliminar", "Delete", new { id=item.RoleId})
        </td>
    </tr>
}

</table>    
</div>
     <div id="showAdd" >        
        @*mostrar la vista parcial, es decir el lugar*@
    </div> 
